import java.util.Scanner;

public class test3 {
    //实现一个方法 sum, 以数组为参数, 求数组所有元素之和.
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入数组个数:");
        int n = sc.nextInt();
        System.out.println("请输入数组的各个数据:");
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        Sum(arr);
    }
    public static void Sum(int[] arr){
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }
        System.out.println("数组各项的和为:"+sum);

    }
}
